import accessEnum from "@/access/accessEnum";
import { UserControllerService } from "@/api-services";
import { StoreOptions } from "vuex";

export default {
  namespaced: true,
  state: () => ({
    loginUser: {
      userName: "",
    },
  }),
  mutations: {
    updateUser(state, payload) {
      state.loginUser = payload;
    },
  },
  actions: {
    async getLoginUser({ commit, state }, payload) {
      const res = await UserControllerService.getLoginUserUsingGet();
      console.log(`output->res`, res);
      // if (res.code === 0) {
      //   commit("updateUser", res.data);
      // } else {
      //   commit("updateUser", {
      //     ...state.loginUser,
      //     userRole: accessEnum.NOT_LOGIN,
      //   });
      // }
    },
  },
} as StoreOptions<any>;
